package com.example.dagger;

import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import com.example.dagger.object.DatabaseObject;
import com.example.dagger.object.HttpObject;

import javax.inject.Inject;

public class SecActivity extends AppCompatActivity {


    @Inject
    HttpObject httpObject;
    @Inject
    HttpObject httpObject2;
    @Inject
    DatabaseObject databaseObject;
   @Inject
    DatabaseObject databaseObject2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sec);
        //  写这些代码之前一定要先去 Build 里面运行一下 ReBuild Project 不然还没有生成 DaggerMyComponent类和里面的各种方法
//        DaggerMyComponent.create().injectMainActivity(this);
//        上下  两段代码的效果都是一样的
//        DaggerMyComponent.builder()
//                .httpModule(new HttpModule())
//                .databaseModule(new DatabaseModule())
//                .build()
//                .injectSecActivity(this);

        ((MyApplication) getApplication()).getAppComponent()
                .injectSecActivity(this);
        Log.e("注入成功了", " " + httpObject.hashCode());
        Log.e("注入成功了", " " + httpObject2.hashCode());
        Log.e("注入成功了", " " + databaseObject.hashCode());
        Log.e("注入成功了", " " + databaseObject2.hashCode());


    }
}